package controllers;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import javax.faces.model.SelectItem;

import model.entities.ChubMapping;
import model.entities.CountriesDist;
import myDaos.DirListDao;

@ManagedBean
@ApplicationScoped
public class ServicesManagedBean implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String country;
	private List<ChubMapping> countrieslist;
	private List<String> clist;
	private List<String> dlist;
	private List<String> ilist;
	private List<SelectItem> interfacesList;
	private List<SelectItem> allCountriesList;
	private List<SelectItem> countryList;
	private List<SelectItem> regionList;
	private String region;
	private String dateNow;
	private List<CountriesDist>countriesDistributorList ; 
	@EJB
	private DirListDao dld;
	
	
	
	

	public List<String> getIlist() {
		return ilist;
	}



	public void setIlist(List<String> ilist) {
		this.ilist = ilist;
	}






	public List<SelectItem> getInterfacesList() {
		return interfacesList;
	}



	public void setInterfacesList(List<SelectItem> interfacesList) {
		this.interfacesList = interfacesList;
	}



	public List<String> getClist() {
		return clist;
	}



	public void setClist(List<String> clist) {
		this.clist = clist;
	}



	public List<SelectItem> getAllCountriesList() {
		return allCountriesList;
	}



	public void setAllCountriesList(List<SelectItem> allCountriesList) {
		this.allCountriesList = allCountriesList;
	}


	public List<SelectItem> getCountryList() {
		return countryList;
	}



	public void setCountryList(List<SelectItem> countryList) {
		this.countryList = countryList;
	}



	public List<SelectItem> getRegionList() {
		return regionList;
	}



	public void setRegionList(List<SelectItem> regionList) {
		this.regionList = regionList;
	}



	public List<String> getDlist() {
		return dlist;
	}



	public void setDlist(List<String> dlist) {
		this.dlist = dlist;
	}



	public String getCountry() {
		return country;
	}



	public void setCountry(String country) {
		this.country = country;
	}



	public String getRegion() {
		return region;
	}



	public void setRegion(String region) {
		this.region = region;
	}



	public String getDateNow() {
		return dateNow;
	}



	public void setDateNow(String dateNow) {
		this.dateNow = dateNow;
	}

	


	public List<ChubMapping> getCountrieslist() {
		return countrieslist;
	}



	public void setCountrieslist(List<ChubMapping> countrieslist) {
		this.countrieslist = countrieslist;
	}

	
	@PostConstruct
	public void init(){
	
		Date myDate = new Date();
		SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yy hh:mm a");
		dateNow = sdf.format(myDate);
		
		regionList = new ArrayList<SelectItem>();
		allCountriesList = new ArrayList<SelectItem>();
		countryList = new ArrayList<SelectItem>();
		interfacesList = new ArrayList<SelectItem>();
		
	    regionList.add(new SelectItem("MA", "Mashreq"));
	    regionList.add(new SelectItem("AR","Arabia" ));
	    
	   clist = dld.getCountriesList(null); 
	   ilist = dld.getAllInterfaces();
	   
	   for(int i = 0; i < ilist.size(); i++) {  
		   interfacesList.add(new SelectItem(ilist.get(i), ilist.get(i)));  
	    }
	   
	    for(int i = 0; i < clist.size(); i++) {  
	    	allCountriesList.add(new SelectItem(clist.get(i), clist.get(i)));  
	    } 
	    
	    countrieslist = dld.getRegionCountriesList(null); 
	    countriesDistributorList = dld.getCountriesDistributorList(null);
	}



	public List<CountriesDist> getCountriesDistributorList() {
		return countriesDistributorList;
	}



	public void setCountriesDistributorList(
			List<CountriesDist> countriesDistributorList) {
		this.countriesDistributorList = countriesDistributorList;
	}
	
	
	
	
	
}
